﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QL_Nha_Sach_Phuong_Nam
{
    public partial class FormDoiMatKhau : Form
    {
        NhanVien nv;
        CXulyDoiMatKhau XulyDoiMatKhau;
        public FormDoiMatKhau(NhanVien n)
        {
            InitializeComponent();
            nv = n;
        }

        private void FormDoiMatKhau_Load(object sender, EventArgs e)
        {
            XulyDoiMatKhau = new CXulyDoiMatKhau();
            if (nv.Role.RoleName == "admin")
            {
                btnchonnhanvien.Enabled = true;
            }
            HienThiNhanVien(nv);
        }

        private void btnsubmit_Click(object sender, EventArgs e)
        {
            nv.NhanVienPass = txtnewpass.Text;
            XulyDoiMatKhau.DoiMatKhau(nv);
            MessageBox.Show("Đã đổi mật khẩu");
        }

        private void btnchonnhanvien_Click(object sender, EventArgs e)
        {
            FormChonNhanVien f = new FormChonNhanVien();
            f.ShowDialog();
            if (f.Nv != null)
                HienThiNhanVien(f.Nv);
        }

        private void HienThiNhanVien(NhanVien nv)
        {
            txtnhanvien.Text = nv.NhanVienName;
            txttenacc.Text = nv.NhanVienAcc;
            txtoldpass.Text = nv.NhanVienPass;
        }
    }
}
